package com.api.shopapi.service.impl;

import com.api.shopapi.entity.JKXuetang;
import com.api.shopapi.entity.dto.JKXuetangDTO;
import com.api.shopapi.mapper.JKXuetangMapper;
import com.api.shopapi.service.JKXuetangService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("JKXuetangServiceImplOne")
public class JKXuetangServiceImpl implements JKXuetangService {

    @Autowired
    private JKXuetangMapper jkXuetangMapper;

    @Override
    public int insert(JKXuetang jkXuetang) {
        return jkXuetangMapper.insert(jkXuetang);
    }

    @Override
    public int update(JKXuetang jkXuetang) {
        return jkXuetangMapper.update(jkXuetang);
    }

    @Override
    public int delete(String jkXuetangCode) {
        return jkXuetangMapper.delete(jkXuetangCode);
    }

    @Override
    public JKXuetang getByJkXuetangCode(String jkXuetangCode) {
        return jkXuetangMapper.getByJKXuetangCode(jkXuetangCode);
    }

    @Override
    public PageInfo<JKXuetang> getPageList(int pageIndex, int pageSize, String userCode,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXuetang> xuetangList = jkXuetangMapper.getPageList(userCode,startTime,endTime);
        return new PageInfo<>(xuetangList);
    }

    @Override
    public PageInfo<JKXuetangDTO> getAdmPageList(int pageIndex, int pageSize, String name, String governmentCode, String startTime, String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXuetangDTO> jkXuetangDTOList = jkXuetangMapper.getAdmPageList(name, governmentCode, startTime, endTime);
        return new PageInfo<>(jkXuetangDTOList);
    }
}
